/*
 * Copyright 2011 ArcBees Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.arcbees.server.auth;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Id;

/**
 * @author Christian Goudreau
 */
public class User {
  @Id
  private String email;
  private String hash;
  private List<String> searchProfileIds = new ArrayList<String>();
  private String dreamHomeId;

  public User() {
  }
  
  public User(String email, String hash){
    this.email = email;
    this.hash = hash;
  }
  
  public User(String email, String hash, List<String> searchProfileIds){
    this.email = email;
    this.hash = hash;
    this.searchProfileIds = searchProfileIds;
  }

  public String getEmail() {
    return email;
  }

  public String getHash() {
    return hash;
  }
  
  public List<String> getSearchProfileIds() {
    return searchProfileIds;
  }

  public String getDreamHomeId() {
    return dreamHomeId;
  }
  
  public void setSearchProfileIds(List<String> searchProfileIds) {
    this.searchProfileIds = searchProfileIds;
  }
  
  public void setDreamHomeId(String dreamHomeId){
    this.dreamHomeId = dreamHomeId;
  }

  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result
        + ((dreamHomeId == null) ? 0 : dreamHomeId.hashCode());
    result = prime * result + ((email == null) ? 0 : email.hashCode());
    result = prime * result + ((hash == null) ? 0 : hash.hashCode());
    result = prime * result
        + ((searchProfileIds == null) ? 0 : searchProfileIds.hashCode());
    return result;
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj)
      return true;
    if (obj == null)
      return false;
    if (getClass() != obj.getClass())
      return false;
    User other = (User) obj;
    if (dreamHomeId == null) {
      if (other.dreamHomeId != null)
        return false;
    } else if (!dreamHomeId.equals(other.dreamHomeId))
      return false;
    if (email == null) {
      if (other.email != null)
        return false;
    } else if (!email.equals(other.email))
      return false;
    if (hash == null) {
      if (other.hash != null)
        return false;
    } else if (!hash.equals(other.hash))
      return false;
    if (searchProfileIds == null) {
      if (other.searchProfileIds != null)
        return false;
    } else if (!searchProfileIds.equals(other.searchProfileIds))
      return false;
    return true;
  }
}
